package com.lebang.controller.sys.cences;

import com.lebang.common.Login;
import com.lebang.domain.CencesIdentityCard;
import com.lebang.model.cences.IdentityCardCount;
import com.lebang.service.sys.MemberCashWithdrawalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;


/**
 * 身份证统计
 *
 * @author xwj
 * @date 2020-04-27
 */
@Controller
@RequestMapping("/sys/cences/cencesidentitycard")
public class CencesIdentityCardController {
    @Autowired
    private MemberCashWithdrawalService memberCashWithdrawalService;


    @Login
    @GetMapping("/list")
    public String list(@RequestParam("star") String star, @RequestParam("end") String end, Model model) {
        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDate starTime = LocalDateTime.parse(star, fmt).toLocalDate();
        LocalDate endTime = LocalDateTime.parse(end, fmt).toLocalDate();
        CencesIdentityCard cencesIdentityCard = new CencesIdentityCard(0);
        List<IdentityCardCount> list = memberCashWithdrawalService.selectDate(starTime, endTime);

        memberCashWithdrawalService.getData(list, cencesIdentityCard);
        model.addAttribute("cencesIdentityCard", cencesIdentityCard);


        return "/cencesidentitycard/edit";
    }


}
